<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	template="/xhtml/template/template.xhtml">

	<ui:define name="breadcrumb">
		<p:breadCrumb>
			<p:menuitem
				value="#{msgs.system_home_title}"
				title="#{msgs.system_home_title}"
				url="/xhtml/index.jsf" />
			<p:menuitem
				value="#{msgs.menu_gerenciamento_title}"
				title="#{msgs.menu_gerenciamento_title}"
				url="#" />
			<p:menuitem
				value="#{msgs.medicos_title}"
				title="#{msgs.medicos_title}"
				url="#" />
		</p:breadCrumb>
	</ui:define>

	<ui:define name="content">
		<h1>
			<h:outputText value="#{msgs.medicos_title}" />
		</h1>
		
		<f:view contentType="text/html">
			<h:form id="mainForm">
			
			<p:messages id="formMessages" showDetail="true" autoUpdate="false"/>
			
			<ui:include src="/xhtml/template/dataexporter-toolbar.xhtml" />

				<p:contextMenu for="dataTable">
					<p:menuitem
						value="#{msgs.global_generic_label_edit}"
						action="#{medicoViewBean.edit}"
						icon="ui-icon ui-icon-pencil"
						disabled="#{not loginHelper.isAdmin()}"
						update="dataTable" />
					<p:menuitem
						value="#{msgs.global_generic_label_delete}"
						icon="ui-icon ui-icon-trash"
						disabled="#{not loginHelper.isAdmin()}"
						update="dataTable"
						oncomplete="handleDeletePopupRequest(xhr, status, args)"
						actionListener="#{medicoViewBean.dialogIfSelected}" />
				</p:contextMenu>

				<p:dataTable
					id="dataTable"
					emptyMessage="#{msgs.primefaces_datatable_empty_message}"
					pageLinks="#{msgs.primefaces_datatable_pagelinks}"
					paginator="true"
					paginatorAlwaysVisible="false"
					rowKey="#{element.crm}"
					rows="10"
					rowsPerPageTemplate="#{msgs.primefaces_table_paginator_rows_per_page_template}"
					selection="#{medicoViewBean.bean}"
					selectionMode="single"
					value="#{medicoViewBean.list}"
					var="element">

					<f:facet name="header">
						<h:outputText value="#{msgs.medicos_datatable_header}" />
					</f:facet>

					<p:column
						sortBy="#{element.nome}"
						filterBy="#{element.nome}"
						headerText="#{msgs.medicos_datatable_nome}">
						<f:facet name="header">
							<h:outputText value="#{msgs.medicos_datatable_nome}" />
						</f:facet>
						<h:outputText value="#{element.nome}" />
					</p:column>
					
					<p:column
						sortBy="#{element.crm}"
						filterBy="#{element.crm}"
						headerText="#{msgs.medicos_datatable_crm}">
						<f:facet name="header">
							<h:outputText value="#{msgs.medicos_datatable_crm}" />
						</f:facet>
						<h:outputText value="#{element.crm}" />
					</p:column>
					
					<p:column
						sortBy="#{element.contato}"
						filterBy="#{element.contato}"
						headerText="#{msgs.medicos_datatable_contato}">
						<f:facet name="header">
							<h:outputText value="#{msgs.medicos_datatable_contato}" />
						</f:facet>
						<h:outputText value="#{element.contato}" />
					</p:column>
					
					<f:facet name="footer">
					</f:facet>

				</p:dataTable>

				<br />

				<p:toolbar>
					<p:toolbarGroup>
						<p:commandButton
							type="submit"
							id="submitButton"
							label="#{msgs.global_generic_label_add}"
							title="#{msgs.global_generic_label_add}"
							value="#{msgs.global_generic_label_add}"
							action="#{medicoViewBean.add}"
							immediate="true"
							disabled="#{not loginHelper.isAdmin()}"
							icon="ui-icon ui-icon-document"
							ajax="false" />
						<p:commandButton
							type="submit"
							id="editButton"
							label="#{msgs.global_generic_label_edit}"
							title="#{msgs.global_generic_label_edit}"
							value="#{msgs.global_generic_label_edit}"
							action="#{medicoViewBean.edit}"
							disabled="#{not loginHelper.isAdmin()}"
							icon="ui-icon ui-icon-pencil"
							ajax="false" />
						<p:commandButton
							type="submit"
							id="deleteButton"
							label="#{msgs.global_generic_label_delete}"
							title="#{msgs.global_generic_label_delete}"
							value="#{msgs.global_generic_label_delete}"
							icon="ui-icon ui-icon-trash"
							update="dataTable, formMessages"
							disabled="#{not loginHelper.isAdmin()}"
							oncomplete="handleDeletePopupRequest(xhr, status, args)"
							actionListener="#{medicoViewBean.dialogIfSelected}"  />
					</p:toolbarGroup>
				</p:toolbar>
			
			</h:form>
		</f:view>


	</ui:define>

	<ui:define name="dialogs">
		<p:confirmDialog
			message="#{msgs.command_delete_confirmation}"
			header="#{msgs.primefaces_confirmDialog_delete_header}"
			id="confirmDeleteDialog"
			widgetVar="confirmDeleteDialogWid">
			<h:form id="confirmDeleteForm">

				<p:commandButton
					id="confirmDeleteButton"
					label="#{msgs.global_generic_label_yes}"
					title="#{msgs.command_confirm_alt}"
					value="#{msgs.global_generic_label_yes}"
					icon="ui-icon ui-icon-trash"
					update=":mainForm:dataTable"
					actionListener="#{medicoViewBean.delete}"
					oncomplete="confirmDeleteDialogWid.hide()" />
				<p:commandButton
					type="button"
					label="#{msgs.global_generic_label_no}"
					title="#{msgs.command_cancel_alt}"
					value="#{msgs.global_generic_label_no}"
					icon="ui-icon ui-icon-close"
					onclick="confirmDeleteDialogWid.hide()" />
			</h:form>

		</p:confirmDialog>
	</ui:define>
</ui:composition>

